package ru.ksu.ktk.diploma.sdi.analyzer.contingency;

/**
 * nominal data represented as pair of nominal values with its frequency count
 * 
 * @author coldflame 29.04.2009 21:21:27
 */
public class NominalData {
    private String firstNominalValue;
    private String secondNominalValue;
    private int count;

    public NominalData(String firstNominalValue, String secondNominalValue, int count) {
        this.firstNominalValue = firstNominalValue;
        this.secondNominalValue = secondNominalValue;
        this.count = count;
    }

    public String getFirstNominalValue() {
        return firstNominalValue;
    }

    public void setFirstNominalValue(String firstNominalValue) {
        this.firstNominalValue = firstNominalValue;
    }

    public String getSecondNominalValue() {
        return secondNominalValue;
    }

    public void setSecondNominalValue(String secondNominalValue) {
        this.secondNominalValue = secondNominalValue;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public void increaseCount(int count) {
        this.count += count;
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) return true;
        if (!(o instanceof NominalData)) return false;
        NominalData n = (NominalData) o;
        return firstNominalValue.equals(n.getFirstNominalValue())
            && secondNominalValue.equals(n.getSecondNominalValue());
    }

    @Override
    public int hashCode() {
        int result = 17;
        if (firstNominalValue != null){
            result = 31 * result + firstNominalValue.hashCode();
        }
        if (secondNominalValue != null){
            result = 31 * result + secondNominalValue.hashCode();
        }

        return result;

    }

}
